package com.huirui.server.controller.admin;

import com.huirui.server.pojo.dto.OrderSettingDto;
import com.huirui.server.pojo.entity.OrderSetting;
import com.huirui.server.pojo.result.Result;
import com.huirui.server.service.OrderSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/order/settings")
@Slf4j
@Validated
@Tag(name = "订单设置", description = "小程序订单设置相关API")
public class OrderSettingController {

    @Resource
    private OrderSettingService orderSettingService;

    @GetMapping
    @Operation(summary = "获取用户的orderSetting")
    public Result<OrderSetting> getOrderSetting() {
        return Result.success(orderSettingService.getOrderSetting());
    }

    @PutMapping
    @Operation(summary = "更改订单设置")
    public Result<Void> updateOrderSetting(@RequestBody @Validated(OrderSettingDto.UpdateGroup.class) OrderSettingDto orderSettingDto) {
        orderSettingService.updateOrderSetting(orderSettingDto);
        return Result.success();
    }

}
